#pragma once
#ifndef yfy_device_h
#define yfy_device_h

#include <stdio.h>
#include <stdint.h>

#define TX_ID_NUM 4
#define RX_ID_NUM 4

#define VOLT_SCALE 100
#define CURR_SCALE 1000

typedef enum {
	INFY_TX_SWITCH = 0,
	INFY_TX_VOLT,
	INFY_TX_CURR,
	INFY_TX_STATUS,
} infy_tx_cmd_e;

typedef enum {
	INFY_RX_SWITCH = 0,
	INFY_RX_VOLT,
	INFY_RX_CURR,
	INFY_RX_STATUS,
} infy_rx_cmd_e;

typedef struct {
	uint32_t id;
	uint8_t dlc;
	uint8_t data[8];
} infy_frame_t;

typedef struct {
	uint32_t tx_id[TX_ID_NUM];
	float curr;
	float volt;
	uint8_t status;
	uint8_t Switch;//0:on 1:off
	int (*can_send_func)(infy_frame_t* frame);
} infy_inst_t;

int infy_device_init(infy_inst_t* inst, const uint32_t* tx_id, int (*can_send_func)(infy_frame_t* frame));
int infy_device_send_swtich(infy_inst_t* inst, uint8_t Switch);
int infy_device_send_voltage(infy_inst_t* inst, float curr, float volt);
int infy_device_send_current(infy_inst_t* inst, float curr, float volt);
int infy_device_send_status(infy_inst_t* inst, uint8_t status);

#endif
